package com.fare.taluo.core.domain.crawl;

import java.io.IOException;
import java.util.Properties;

import com.fare.taluo.conf.ConfigContainer;
import com.fare.taluo.conf.ConfigLocalLoader;
import com.fare.taluo.conf.PropertiesConfigLocalLoader;

/**
 * 抓取配置文件加载器
 * @author xiangsf 2013-05-23
 *
 */
public class CrawlPropertiesLoader extends PropertiesConfigLocalLoader
												implements ConfigLocalLoader{
	
	public final static String CONFIG_FILE = "crawl.properties";

	public String getFileName() {
		return CONFIG_FILE;
	}

	@Override
	public void load(){
		prop = null;
		try {
			prop = new Properties();
			prop.load(this.getClass().getClassLoader().getResourceAsStream(this.getFileName()));
		} catch (IOException e) {
			e.printStackTrace();
			logger.error(String.format("加载配件文件[%s]出错!", this.getFileName()), e);
		}
		if(prop != null) ConfigContainer.getInstance().registerCache(this.getFileName(), prop);
		
		this.setHasLoad(true);
	}
	
	
}
